function [ y] = mis( theta, id)
load('mainfile1.mat')

alpha=-theta(1);
beta=theta(3:6); % <1x5 double>
mu=theta(7:31).*10;  % <1x25 double>
chi=theta(34:58);% <1x25 double>
rho=theta(59:62)./5;
c=theta(64);

sum=0;
n=find(consumer_id==id);
k=dimension(n(1));
m1=n(1);
m2=n(1)+k-1;
s= brandid(m1:m2)'
for i=1:1:k
    j=s(i);
    muu=mu(j);%%%
    x(n(1),:)*beta';%%%
    cons=x(n(1),:);%%%
    beta';%%%
    alpha;%%%
    chii=chi(j);%%%
    delta= mu(j) + x(n(1),:)*beta'+alpha*chi(j);
    sum=sum+exp(delta);
end 
c;%%%
flg=x(n(1),:)* rho';%%%
cost=k*[c+x(n(1),:)* rho']; %cost must be positive
y=log(1+sum)-cost;
end

